package com.socket.tools.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;

/**
 * 消息模型
 */
public class Message {
    
    public enum MessageType {
        CONNECT_REQUEST,    // 连接请求
        CONNECT_ACCEPT,     // 接受连接
        CONNECT_REJECT,     // 拒绝连接
        CONNECT_RELEASE,    // 释放连接
        CHAT_MESSAGE,       // 聊天消息
        SYSTEM_MESSAGE,     // 系统消息
        HEARTBEAT,         // 心跳消息
        REMOVE_REQUEST,    // 移除连接请求
        ONLINE_ADMINS,      // 在线管理员信息
        REMOVE_CONNECTED_REQUEST, //清除在线会话
        REJECT_REQUEST, //连接拒绝
        CONNECT_SUCCESS, //连接成功
        CONNECT_FAILD, //连接失败
        CLEAR_ALL //所有会话清理标识（包括服务端和客户端）
    }
    
    private MessageType type;
    private String from;
    private String to;
    private String content;
    private String sessionId;
    private java.util.List<String> admins; // 在线管理员列表
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date timestamp;
    
    public Message() {
        this.timestamp = new Date();
    }
    
    public Message(MessageType type, String from, String content) {
        this();
        this.type = type;
        this.from = from;
        this.content = content;
    }

    public Message(MessageType type, String from, String content,String sessionId) {
        this();
        this.type = type;
        this.sessionId = sessionId;
        this.from = from;
        this.content = content;
    }
    
    // Getters and Setters
    public MessageType getType() {
        return type;
    }
    
    public void setType(MessageType type) {
        this.type = type;
    }
    
    public String getFrom() {
        return from;
    }
    
    public void setFrom(String from) {
        this.from = from;
    }
    
    public String getTo() {
        return to;
    }
    
    public void setTo(String to) {
        this.to = to;
    }
    
    public String getContent() {
        return content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }
    
    public String getSessionId() {
        return sessionId;
    }
    
    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }
    
    public Date getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }
    
    public java.util.List<String> getAdmins() {
        return admins;
    }
    
    public void setAdmins(java.util.List<String> admins) {
        this.admins = admins;
    }
    
    @Override
    public String toString() {
        return "Message{" +
                "type=" + type +
                ", from='" + from + '\'' +
                ", to='" + to + '\'' +
                ", content='" + content + '\'' +
                ", sessionId='" + sessionId + '\'' +
                ", admins=" + admins +
                ", timestamp=" + timestamp +
                '}';
    }
} 
